//
//  AuctionCell.swift
//  LeGou
//
//  Created by lxm on 2022/10/15.
//

import UIKit

class AuctionCell: XMBaseTableViewCell {
    @IBOutlet weak var name: UILabel!
    
    @IBOutlet weak var dateNumContent: UIView!
        
    @IBOutlet weak var moneyBtn: UIButton!
    
    @IBOutlet weak var currentMoney: UILabel!
    
    @IBOutlet weak var dqj: UILabel!
    
    @IBOutlet weak var successIcon: UIImageView!
    
    @IBOutlet weak var avatar: UIImageView!
    
    @IBOutlet weak var jion: UIButton!
    
    @IBOutlet weak var dateNum: UILabel!
    
    @IBOutlet weak var otherJion: UILabel!
    
    @IBOutlet weak var markPrice: UILabel!
    
    var jpBtnLeftColor = "#F07650".zm.hex()
    var jpBtnRightColor = "#DC1927".zm.hex()
    
    
    @IBOutlet weak var alerView: AuctionAlertView!
    
    @IBOutlet weak var auctionBtn: AuctionButtonView!
    
    let tan = DetailShareView.TriangleView()
    
    override func awakeFromNib() {
        super.awakeFromNib()
        tan.direction = .down
        tan.fillColor = UIColor.zm.color(hexString: "#FFDA18")
        addSubview(tan)
        tan.snp.makeConstraints { make in
            make.top.equalTo(jion.snp.bottom)
            make.centerX.equalTo(jion)
            make.width.equalTo(5)
            make.height.equalTo(3.5)
        }

        // Initialization code
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        ZMUtil.clipCircle(view: dateNumContent, Corner: [.bottomRight], radius: 9)
    }

    func setStyle(type : AuctionModels.BidState) {
//        jpBtn.isHidden = false
        if type == .wait {
            // 即将开始
            dqj.textColor = "#48A1A7".zm.hex()
            currentMoney.textColor = "#48A1A7".zm.hex()
            successIcon.isHidden = true
            jion.isHidden = true
            tan.isHidden = true
            alerView.isHidden = false
            auctionBtn.isHidden = true
        } else if type == .process {
            dqj.textColor = Style.mainColor
            currentMoney.textColor = Style.mainColor
            successIcon.isHidden = true
            jion.isHidden = false
            tan.isHidden = false
            alerView.isHidden = true
            auctionBtn.isHidden = false
        } else if type == .toNext {
            dqj.textColor = Style.mainColor
            currentMoney.textColor = Style.mainColor
            successIcon.isHidden = true
            jion.isHidden = true
            tan.isHidden = true
            alerView.isHidden = true
            auctionBtn.isHidden = true
        } else {
            dqj.textColor = Style.mainColor
            currentMoney.textColor = Style.mainColor
            successIcon.isHidden = false
            jion.isHidden = true
            tan.isHidden = true
            alerView.isHidden = true
            auctionBtn.isHidden = true
        }
    }
    
    // 0 : 竞购 1:提醒 2：取消提醒
    func setJionButtonStyle(type : Int) {
        if type == 0 {
            alerView.isHidden = true
            auctionBtn.isHidden = false
        } else if type == 1 {
            alerView.isHidden = false
            auctionBtn.isHidden = true
            alerView.setJionButtonStyle(type: 0)
        }
        else {
            alerView.isHidden = false
            auctionBtn.isHidden = true
            alerView.setJionButtonStyle(type: 1)
        }
    }
    
}
